home *** CD-ROM | disk | FTP | other *** search
- terse specify abbreviated listing format
- ;****************************************************************
-
- ; Copyright (c) 1987 by Grand Canyon Code Factory
- ; No rights reserved
-
- ; This is a simple application that you can easily customize.
- ; It writes your name in a note alert. It is mostly to familiarize you
- ; with using an assembler. You will need the shareware assembler
- ; McAssembly as well as the .PSM files available from this SIG. You
- ; should also have EDIT from Apple, also available from AMUG. McAssembly
- ; works best with EDIT if you rename McAssembly "ASM" on your working
- ; disk.
-
- ; This file includes both Easy.asm and Easy.job. If you look at
- ; the end of this file you will see that there are two lines that you
- ; are asked to cut and paste into a separate text file called Easy.job.
- ; You can also find a place where you are asked to replace the name
- ; "John Doe" with your own name. If your name happens to be John Doe,
- ; you don't have to make this change. You will also find an "ipath"
- ; pseudo-op below ( a pseudo-op is a message to the assembler that doesn't
- ; actually generate machine language ). There are instructions at the
- ; ipath for setting it up to match your disk. You can even use more than
- ; one ipath if for some strange reason you want to put your include files
- ; in different folders.
-
- ; Once you have replaced John Doe with your own name, fixed the ipath,
- ; and saved Easy.job you can transfer directly to McAssembly by choosing
- ; ASM from EDIT's transfer menu. Don't worry if it says something like
- ; "ASM Easy.asm." When you get into McAssembly choose "Run job" from
- ; the file menu if all goes well you should see a bunch of messages about
- ; the assembly and and the link, ending with a "Job is Done" message.
- ; If the message above that is "OK - no errors in the link" you can
- ; be fairly sure that all has gone well. You can quit to the finder and
- ; see your new application or just transfer to easy from using McAssembly's
- ; transfer menu and run it.
-
- ; When you do get back to the desktop you'll see a file named Easy.rel
- ; along with your new application named Easy. If you don't know what
- ; .rel files are all about don't worry, you can throw it away. We we
- ; eventually cover .rel files, explaining why the assembler makes them
- ; and what the're good for. For you 'C' and Pascal folks, let me pique
- ; your curiosity by saying that when your manual talks about "linking
- ; to assembly language, remember that the .rel file is what your compiler
- ; needs to do the link.
-
- ; When you get bored with your new program, come back and read this file.
- ; The comments have some usefull information.
-
- ; This program has been placed in the public domain by Grand Canyon
- ; Code Factory. You may use it, modify it, or change it in any way you
- ; see fit.
-
- ;****************************************************************
-
- title "Hello World $" title for listing with timestamp
-
- ;****************************************************************
- ; If you haven't figured it out by now, anything that comes after a ";"
- ; is a comment. In assembler a separator is one or more tabs or spaces.
- ; The syntax of an assembly language line is LABEL in column one,
- ; then a separator then the OPCODE, another separator, the ADDRESS,
- ; another separator then a comment. If you want to have a line with only
- ; a comment, you have to start with the ";". You can include blank lines
- ; wherever you want for readability.
- ;****************************************************************
-
- ;Configure our application file:
-
- ftype 'APPL' file type
- fsign 'GCCF' file creator signature
- a5off $100 Color QuickDraw, you pig!
-
- ;****************************************************************
- ;Include trap definitions & equate files:
-
- ; The ipath assumes you have an HFS disk called 'Assembler' which
- ; contains a folder named 'Include files' which contains all
- ; of these includes. If you have a different setup, then you'll
- ; have to change ipath accordingly.
-
- ipath "Assembler:Include files:" folder with includes
-
- Incl "SysEqu.psm" system equates
- incl "QuickEqu.PSM" quick draw equates
- incl "ToolEqu.PSM" toolbox equates
- incl "RegisterTraps.PSM" register-based trap words
- incl "SysErr.PSM" system error code equates
- incl "FSEqu.PSM" file system equates
- incl "PackMacs.PSM" package equates
- incl "Symbol.PSM" my own stuff
-
- ; I use an "everything including the kitchen sink" approach when it
- ; comes to includes. That way I can refer to everything documented in
- ; Inside Mac by name. This approach works fine unless you're trying
- ; to assemble in 128K. If anyone is and this won't assemble, leave me a
- ; message.
-
- ;****************************************************************
-
- tcomp tcomp is magic! It tells the assembler that even
- ; though we're assembling and not compiling when we
- ; call ROM we want to use "Pascal style." This saves
- ; rummaging about in IM for the assembler forms of
- ; ROM calls. In fact, once we say tcomp we can use
- ; either form. It only works for stack based traps
- ; though.
-
- ;****************************************************************
- ; This is our variable storage area off of A5. Don't worry if this
- ; doesn't make sense yet. I'll try to explain all this in the hardware
- ; write up. For now just understand that this tells the mac to save
- ; two bytes of space for TheItem in it's global variable area. If you
- ; can't wait to understand this, Chapter 3 the in first volume of
- ; Chernicoff explains it very well.
-
- A5sec
- TheItem integer
- A5end
-
- ;****************************************************************
- ; Start up by initializing the managers. Every stand-alone program
- ; should start just this way.
-
- Start InitGraf !-4(a5) init QuickDraw with space for its use
- InitFonts init Font Manager
- InitWindows init Window Manager
- InitMenus init Menu Manager
- InitDialogs #Nil init Dialog Manager (no restart proc)
-
- ; Note the # sign in front of Nil. In assembly language we always
- ; have to tell the assembler if someting is a number. Otherwise,
- ; the assembler will assume it's an address.
-
- TEInit init Text Edit
-
- ; FlushEvents is register based, not really part of the toolbox event
- ; manager but rather of the down and dirty OS event manager. Therefore,
- ; there is no fancy trap compiler form for FlushEvents. We have to do this
- ; hacker style, cram a long in a register and inline a trap.
-
- MOVE.L #$0000FFFF,D0 no stop in high word, everyevent in low word
- _FlushEvents flush all pending events
- InitCursor init cursor to arrow
- NoteAlert #1001,#Nil,TheItem
- RTS We can bail out this way because the segment loader
- ; politely left Finders address on the stack.
-
- ; The rest of this isn't code at all. This is for McAssembly's
- ; resource compiler. This all could have been done with ResEdit.
-
- $$ALRT,1001,%00100000,Hello Alert an alert named Hello Alert
- ; The %00100000 sets the attribute byte. We could have used hex but binary
- ; is more WYSIWYG.
- 90,100,240,400 top, left, bottom, right
- 1001 item list ID
- %0101010101010101 stages
-
- $$DITL,1001,%00100000,Hello Item List the item list for Hello Alert
- 2 two items
-
- 0 place holder for handle
- 115,110,140,140 top, left, bottom, right
- ctrlItem+btnCtrl,OK the OK button
-
- 0 place holder for handle
- 80,5,100,280 top,left,bottom, right
- ; type your own name instead of John Doe on the next line
- statText+itemDisable,Hello World! I'm John Doe
-
- end
- ; cut the next two lines and save them in the separate file Easy.job.
- Easy
- /Easy